import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/controllers/base/base_controller.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'state.dart';

class LightSleepLogic extends BaseController {
  final LightSleepState state = LightSleepState();

  goBackSleepPage() {
    Get.back();
  }

  @override
  String getRemotePath() {
    throw '';
  }

  @override
  void initState() {
    state.percentValue = Get.arguments['value'] ?? 0;
    state.level = Get.arguments['level'] ?? '';
    state.color = Get.arguments['color'] ?? 0x00000000;
  }

  @override
  void onRemoteEvent(event, method) {
    // TODO: implement onRemoteEvent
  }

  String getPercentValueText() {
    return '${state.percentValue}%';
  }

  /// 浅睡比例参考值计算:浅睡比例:小于55%为正常，大于等于55%为偏高.
  getLevelText() {
    if (state.percentValue < 55) {
      return Text(LocaleKeys.sleep_ratio_normal.ts, style: TextStyle(color: Colors.white, fontSize: 48.sp));
    } else {
      return Text(LocaleKeys.sleep_ratio_height.ts, style: TextStyle(color: Colors.white, fontSize: 48.sp));
    }
  }

  getContainerColor() {
    if (state.percentValue < 55) {
      return Colors.green;
    } else {
      return Colors.red.withOpacity(0.6);
    }
  }
}
